package cn.edu.seu.ssny.dao;

import cn.edu.seu.ssny.dao.support.IBaseDao;
import cn.edu.seu.ssny.entity.MachineGroup;
import cn.edu.seu.ssny.entity.Project;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface IMachineGroupDao extends IBaseDao<MachineGroup, Integer> {

    MachineGroup findMachineGroupByProjectAndAndName(Project project, String name);

    List<MachineGroup> findMachineGroupsByProjectOrderByName(Project project);

    @Query(value = "select device_id from tb_machine_group_config where machine_group_id=?1", nativeQuery = true)
    List<Integer> findDeviceIdsByMachineGroupId(Integer machineGroupId);

    @Query(value = "select device_id from tb_machine_group_config where machine_group_id=?1 and type=?2", nativeQuery = true)
    List<Integer> findDeviceIdsByMachineGroupIdAndType(Integer machineGroupId, Integer type);
}
